package com.example.shiyan3.controller;

import com.example.shiyan3.pojo.VirusDate;
import com.example.shiyan3.others.GetDate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Graycat
 * @Date: 2020/5/8 12:47
 * Create by lwj.
 */
@Controller
public class MyController {

    @RequestMapping("/getIndex")
    public String index( HttpServletRequest request ){
        request.getSession().setAttribute("virusList",GetDate.confirmedList);
        return "index.html";
    }
    @RequestMapping("/search")
    public String searchByCountry( String searchInput, HttpServletRequest request ){
        List<VirusDate> searchList = new ArrayList();
        for ( VirusDate item : GetDate.confirmedList ){
            if( item.getCountry().equals(searchInput) ){
                searchList.add(item);
            }
        }
        request.getSession().setAttribute("searchList",searchList);
        return "searchResult.html";
    }
}
